const type_list = new Vue({
    el : "#type-list",
    data : function () {
        return {
            view : {
                pictureResource : true,
                userResources : false
            }
        }
    },
    methods : {
        update : function () {

        },
        select : function (index) {
            this.view.userResources = false
            this.view.pictureResource = index === 0;
            if (index === 1){
                this.view.userResources = true
            }
        }
    }
})
/*图片资源*/
const picture_resources = new Vue({
    el : "#picture-resources",
    data : function () {
        return {
            view : type_list.$data.view,
            name : "",
            imgname : ""
        }
    },
    methods: {
        searchResources : function () {
            let timestamp = new Date()
            this.imgname = "/resources/" + this.name + ".jpg?t="  + timestamp.valueOf()
        }
    }
})
const user_resources = new Vue({
    el : "#user-resources",
    data : function () {
        return {
            view : type_list.$data.view,
            username: "",
            user : {
                username : "",
                role_name : ""
            }
        }
    },
    methods : {
        queryUser : function () {
            $.post("/manage/selectUserByUsername", {
                username : this.username
            }, function (data) {
                const json = $.parseJSON(data)
                console.log(json)
                if (json.code === 0){
                    user_resources.user.username = user_resources.username
                    user_resources.user.role_name = json.object.role.name
                } else {
                    layer.alert(json.msg, {
                        icon: 2,
                        skin: 'layer-ext-moon'
                    })
                }
            })
        }
    }
})